﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Helpers;

namespace MyInspiration.Models
{
    public class MyAntiForgeryAdditionalDataProvider : IAntiForgeryAdditionalDataProvider
    {
        private const string TokenKey = "SingleTokenKey";


        public string GetAdditionalData(HttpContextBase context)
        {
            var token = Guid.NewGuid().ToString();
            context.Session.Add(TokenKey, token);
            return token;

            //return "7531d6c3-51f9-4e3f-a033-3c756b3e719f";
        }

        public bool ValidateAdditionalData(HttpContextBase context, string additionalData)
        {
            var token = context.Session[TokenKey].ToString();
            context.Session.Remove(TokenKey);
            return token == additionalData;
            //return additionalData == "7531d6c3-51f9-4e3f-a033-3c756b3e719f";
        }
    }
}